package com.shawn.function;

import java.util.function.Function;

/**
 * function demo
 * @author shawn
 */
public class FunctionDemo {

	public static void main(String[] args) {
		Function<String, Integer> func = new Function<String, Integer>() {
			@Override
			public Integer apply(String s) {
				return s.length();
			}
		};
		System.out.println("匿名内部类方式： " + func.apply("hello,world"));

		Function<String, Integer> func2 = (s) ->{
			return s.length();
		};
		System.out.println("lambda expression方式： " + func2.apply("hello,world"));
	}

}
